import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:setting_test01/login_background.dart';
import 'package:setting_test01/dashboard/dashboard_menu_row.dart';
import 'package:setting_test01/dashboard/dashboard_menu_row_two.dart';
import 'package:setting_test01/profile_tile.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

class DashboardOnePage extends StatelessWidget {

  late Size deviceSize;

  Widget appBarColumn(BuildContext context) {
    return SafeArea(
      child: Padding(
        padding: EdgeInsets.symmetric(horizontal:4.0,vertical:18.0),
        child: Column(
          children: <Widget>[
            Row(
              mainAxisAlignment:MainAxisAlignment.spaceBetween,
              children: <Widget>[
                IconButton(
                  icon: Icon(defaultTargetPlatform == TargetPlatform.android ? Icons.arrow_back : Icons.arrow_back_ios,color: Colors.white),
                  onPressed: () => Navigator.canPop(context)? Navigator.pop(context) : null,
                ),

                ProfileTile(
                  title:"Hi, Pawan Kumar",
                  subtitle: "Welcome to Earth",
                  textColor: Colors.white,
                ),

                IconButton(
                  icon: Icon(Icons.more_vert,color: Colors.white),
                  onPressed: (){
                    print("hi somebody");
                  },
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }


  Widget searchCard() {
    return Padding(
      padding: EdgeInsets.all(8.0),
      child: Card(
        elevation:2.0,
        child:Padding(
          padding: EdgeInsets.all(8.0),
          child:Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Icon(Icons.search),
              SizedBox(width:10.0),
              Expanded(
                child: TextField(
                  decoration: InputDecoration(
                    border: InputBorder.none,
                    hintText: "Find it",
                  ),
                ),
              ),
              Icon(Icons.menu),
            ],
          ),
        ),
      ),
    );
  }

  Widget actionMenuCard(){
    return Padding(
      padding: EdgeInsets.symmetric(horizontal:8.0),
      child: Card(
        elevation: 2.0,
        child: Padding(
          padding: EdgeInsets.all(8.0),
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                DashboardMenuRow(
                  firstIcon: FontAwesomeIcons.solidUser,
                  firstLabel: "Friends",
                  firstIconCircleColor: Colors.blue,
                  secondIcon: FontAwesomeIcons.userFriends,
                  secondLabel: "Groups",
                  secondIconCircleColor: Colors.orange,
                  thirdIcon: FontAwesomeIcons.mapMarkerAlt,
                  thirdLabel: "Nearby",
                  thirdIconCircleColor: Colors.purple,
                  fourthIcon: FontAwesomeIcons.locationArrow,
                  fourthLabel: "Moment",
                  fourthIconCircleColor: Colors.indigo,
                ),
                DashboardMenuRow(
                  firstIcon: FontAwesomeIcons.images,
                  firstLabel: "Albums",
                  firstIconCircleColor: Colors.red,
                  secondIcon: FontAwesomeIcons.solidHeart,
                  secondLabel: "Likes",
                  secondIconCircleColor: Colors.teal,
                  thirdIcon: FontAwesomeIcons.solidNewspaper,
                  thirdLabel: "Articles",
                  thirdIconCircleColor: Colors.lime,
                  fourthIcon: FontAwesomeIcons.solidCommentDots,
                  fourthLabel: "Reviews",
                  fourthIconCircleColor: Colors.amber,
                ),
                DashboardMenuRow(
                  firstIcon: FontAwesomeIcons.footballBall,
                  firstLabel: "Sports",
                  firstIconCircleColor: Colors.cyan,
                  secondIcon: FontAwesomeIcons.solidStar,
                  secondLabel: "Fav",
                  secondIconCircleColor: Colors.redAccent,
                  thirdIcon: FontAwesomeIcons.blogger,
                  thirdLabel: "Blogs",
                  thirdIconCircleColor: Colors.pink,
                  fourthIcon: FontAwesomeIcons.wallet,
                  fourthLabel: "Wallet",
                  fourthIconCircleColor: Colors.brown,
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }

  Widget balanceCard(){
    return Padding(
      padding: EdgeInsets.all(8.0),
      child: Card(
        elevation: 2.0,
        child: Padding(
          padding: EdgeInsets.all(20.0),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Text(
                    "Balance",
                    style:TextStyle(fontFamily: "Raleway"),
                  ),
                  Material(
                    color:Colors.black,
                    shape: StadiumBorder(),
                    child: Padding(
                      padding: EdgeInsets.all(8.0),
                      child: Text(
                        "500 Points",
                        style: TextStyle(color: Colors.white,fontFamily: "Raleway"),
                      ),
                    ),
                  ),
                ],
              ),

              Text(
                " 1000",
                style: TextStyle(
                  fontFamily: "Raleway",
                  fontWeight: FontWeight.w700,
                  color: Colors.green,
                  fontSize:25.0,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget allCards(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        children: <Widget>[
          appBarColumn(context),
          SizedBox(
            height:deviceSize.height * 0.1,
          ),
          searchCard(),
          SizedBox(
            height:deviceSize.height * 0.1,
          ),
          actionMenuCard(),
          SizedBox(
            height:deviceSize.height * 0.1,
          ),
          balanceCard(),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    deviceSize = MediaQuery.of(context).size;
    return Scaffold(
      body: Stack(
        fit: StackFit.expand,
        children: <Widget>[
          LoginBackground(
            showIcon: false,
          ),
          allCards(context),
        ],
      ),
    );
  }
}
